<?php
  $total = 77;
  $cols = 9;
  $rows = ceil($total / $cols);
  $count = 1;
?>

<table border="1" width="80%" align="center" cellpadding="10">
<?php

  for ($i = 1; $i <= $rows ; $i++)
  {
    $color = $i%2==0 ? 'pink':'lightgreen';
?>
  <tr>
<?php
  for ($j = 1; $j <= $cols; $j++)
  {
    if($count <= $total) {
?>
    <td style="background:<?=$color?>">Table Data <?=$count++?></td>
<?php
    } else {//end if
?>
    <td style="background:<?=$color?>">&nbsp;</td>

<?php
    }//end else
  }// end inner for
?>
  </tr>
<?php
  }// end for()
?>
</table>


